package com.wuad.platformwuad.server;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 项目启动后要执行的方法
 *
 * @author wuad
 */
@Slf4j
@Component
public class HighOrderCommandLineRunner implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {

    }

//    @Value("${datasource.driver-class-name}")
//    public String driverClassName;
//    @Value("${datasource.url}")
//    public String url;
//    @Value("${datasource.username}")
//    public String userName;
//    @Value("${datasource.password}")
//    public String passWord;

//    @Override
//    public void run(String... args) throws Exception {
//        new Thread() {
//            @Override
//            public void run() {
//                log.info("--------工作流表检测---------");
//                ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
////                processEngineConfiguration.setJdbcDriver("com.mysql.cj.jdbc.Driver");
////                processEngineConfiguration.setJdbcUrl("jdbc:mysql://localhost:3306/platform_wad?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true");
////                processEngineConfiguration.setJdbcUsername("root");
////                processEngineConfiguration.setJdbcPassword("root");
//                //DB_SCHEMA_UPDATE_TRUE 如果表不存在 自动创建表
//                processEngineConfiguration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
//                //工作流核心对象 processEngine
//                ProcessEngine processEngine1 = processEngineConfiguration.buildProcessEngine();
//                log.info("--------表创建完成:{}", processEngine1);
//                if (null != processEngine1) {
//                    String name  = "助农点审批流程";
//                    log.info("-----------------------------流程检测--------------------------");
//                    // 创建ProcessEngineConfiguration对象
//                    ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
//                    ProcessEngine processEngine = configuration.buildProcessEngine();
//                    //获取RepositoryService对象
//                    RepositoryService repositoryService = processEngine.getRepositoryService();
//                    Deployment deployment = repositoryService.createDeploymentQuery().deploymentName(name).singleResult();
//                    if (null == deployment) {
//                        log.info("-----------------------------流程创建--------------------------");
//                        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("processes/bank.zip");
//                        ZipInputStream zipInputStream = new ZipInputStream(inputStream);
//                        //进行部署
//                        Deployment deployment1 = repositoryService
//                                .createDeployment()
//                                .addZipInputStream(zipInputStream)
//                                .name(name)
//                                // 部署
//                                .deploy();
//                        log.info("-----------------------------流程创建成功--------------------------");
//                    }
//                    log.info("-----------------------------流程检测结束--------------------------");
//                }
//            }
//        }.start();
//    }
}
